/**
 * 登录相关接口
 */
import { authRequest, request } from '@/utils/request'
import { getRefreshToken } from '@/utils/storage'

/** 微信用户一键登录 */
export function login(data) {
  return authRequest.post('/oauth2/token', {
    header: {
      'Authorization': 'Basic c29jaWFsOnNvY2lhbA==',
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data,
  })
}

/** 刷新 token */
export function refreshToken() {
  return request.post(`/oauth/refresh-token?refreshToken=${getRefreshToken()}`)
}

/** 获取用户信息 */
export function fetchUserInfo() {
  return request.get('/user/info')
}

/** 获取登录用户信息 */
export function getUserInfo() {
  return request.get('/user/infoApp')
}

// 根据code和电话查询数据
export function getPhoneByCode(params) {
  return request.get('/user/getInfoByCode', {
    data: params,
  })
}
